<?php
$room_id=$_GET['m'];
?>
<style type="text/css">
.body {
}
#boxuser{
	background-color: #444041;
	height: auto;
	width: 760px;
}
body,td,th {
	color: #FFF;
}
</style>

<?php
 $sql_m = "select * from tb_room NATURAL JOIN tb_class NATURAL JOIN tb_course WHERE room_id='{$room_id}' ORDER BY class_id,course_id,room_lv";
 $result_m = $dbfunc->query($sql_m);
//ดึงข้อมูลแบบอาร์เรย์  โดยเลือกแสดงแค่เรคคอร์ดเดียว (ไม่ใช้ while)
$fetch = mysql_fetch_array($result_m);
?>

<div id="boxuser">
<form action="?module=admin&page=update_room" method="post" enctype="multipart/form-data" name="frm_room" id="frm_room">
<input value="<?php echo $fetch['room_id']; ?>" name="old_id" />
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0" id="show_menu">
    
    <tr>
      <th height="35" colspan="3" align="center" bgcolor="#999999">กรุณากรอกข้อมูลวิชาเรียน</th>
    </tr>
    
    <tr>
      <td width="359" height="35" align="right" bgcolor="#999999"><table width="50%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th width="6%" height="33" scope="col">&nbsp;</th>
          <td width="94%" align="left" scope="col"><span class="style_1">รหัสห้องเรียน</span></td>
        </tr>
      </table></td>
      <td width="10" height="35" bgcolor="#999999">:</td>
      <td width="390" height="35" bgcolor="#999999"><span class="style_1">
        <input name="room_id" type="text" id="room_id" size="30" maxlength="40" value="<?php echo $fetch['room_id']; ?>" />
      </span></td>
    </tr>        
    <tr>
      <td height="35" align="right" bgcolor="#999999"><table width="50%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th width="6%" height="30" scope="col">&nbsp;</th>
          <td width="94%" align="left" scope="col"><span class="style_1">หลักสูตร</span></td>
        </tr>
      </table></td>
      <td height="35" bgcolor="#999999">:</td>
      <td height="35" bgcolor="#999999">
        <select name="course_id">
            <?php
            $sql = "select * from tb_course";
            $result = $dbfunc->query($sql);
            while($row = mysql_fetch_array($result)){
            ?>
            <option value="<?php echo $row['course_id']; ?>" <?php if($fetch['course_id']==$row['course_id']){ echo 'selected'; } ?>><?php echo $row['course_name']; ?></option>
            <?php } ?>
        </select>
        </td>
    </tr>
    <tr>
      <td height="35" align="right" bgcolor="#999999"><table width="50%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th width="6%" height="30" scope="col">&nbsp;</th>
          <td width="94%" align="left" scope="col"><span class="style_1">ชั้นปีที่</span></td>
        </tr>
      </table></td>
      <td height="35" bgcolor="#999999">:</td>
      <td height="35" bgcolor="#999999">
        <select name="room_lv">
            <? $i = 1; while($i <= 8){ ?>
            <option value="<?php echo $i; ?>" <?php if($i == $fetch['room_lv']){ echo 'selected'; } ?>><?php echo $i; ?></option>
            <? $i++; } ?>
        </select>
      </td>
    </tr>
    <tr>
      <td height="35" align="right" bgcolor="#999999"><table width="50%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th width="6%" height="30" scope="col">&nbsp;</th>
          <td width="94%" align="left" scope="col"><span class="style_1">คำอธบายห้องเรียน</span></td>
        </tr>
      </table></td>
      <td height="35" bgcolor="#999999">:</td>
      <td height="35" bgcolor="#999999"><input type="text" name="room_des" value="<?php echo $fetch['room_des']; ?>" /></td>
    </tr>
    <tr>
      <td height="35" bgcolor="#999999">&nbsp;</td>
      <td height="35" bgcolor="#999999">&nbsp;</td>
      <td height="40" bgcolor="#999999"><span class="style_1">
        <input type="submit" name="Submit" id="Submit" value=" บันทึก  " />
      </span></td>
    </tr>
    <tr>
      <td height="36" bgcolor="#999999">&nbsp;</td>
      <td bgcolor="#999999">&nbsp;</td>
      <td bgcolor="#999999">&nbsp;</td>
    </tr>
  </table>
  
  <p>&nbsp;</p>
</form>
</div>